Many computer processors contain exception handlers. Exception handlers are well known in the art. They are utilized in processors to process non-routine instructions. Non-routine instructions invoke an exception condition either before, during, or after executing an instruction.
When an exception condition is noted during the execution of an instruction, normal processing is interrupted and the processor must save the context of the interrupted process by noting the process status of each instruction currently in process. Each exception has an associated vector to locate a corresponding exception handling routine. The exception handler then performs a sequence of actions either in the firm of a software routine or in the form of hardware computation to determine the cause of the exception condition and processes the exception condition by performing any function the exception requires. After the exception condition is handled, the processor returns to the normal process for each instruction that was being processed at the process point for each such instruction when the exception condition occurred. Moreover, each exception handler can itself invoke exception handlers.
A network switch or router is a system that processes network data packets. Similar to a computer processor, a network switch or router may encounter exception conditions during the course of processing a network data packet.
A common technique called pipelining is employed to increase the rate of processing in computer processors and network switches and routers. Pipelining causes the data packet to traverse multiple processing stages in a serial manner. Each processing stage completes a part of the entire processing necessary.
In a pipelined processor, exception conditions may be detected in every stage. Some exception conditions, although detected in different stages, require the same exception handling. If exception handlers were attached to processing stages, a particular exception handler needs to be replicated and each instance attached to a different stage. Also, an exception handler attached to a processing stage may be required to modify the processing already completed by previous processing stages or previous exception handlers. This leads to exception handlers that are complex and large in number.
Thus, there exists a need for a more efficient and improved method and apparatus for detecting and handling exceptions.